package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.RescueRecordMapper;
import com.gc.business.domain.RescueRecord;
import com.gc.business.service.IRescueRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 救援记录 服务层实现
 * 
 * @author liujinteng
 * @date 2020-11-21
 */
@Slf4j
@Service
public class RescueRecordServiceImpl extends ServiceImpl<RescueRecordMapper, RescueRecord> implements IRescueRecordService {

    @Override
    public List<RescueRecord> list(RescueRecord rescueRecord){
        LambdaQueryWrapper<RescueRecord> wrapper = new LambdaQueryWrapper<>();
        if(rescueRecord != null){
            if(StringUtils.isNotEmpty(rescueRecord.getRecordId())){
                wrapper.eq(RescueRecord::getRecordId, rescueRecord.getRecordId());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getTiringId())){
                wrapper.eq(RescueRecord::getTiringId, rescueRecord.getTiringId());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getUserId())){
                wrapper.eq(RescueRecord::getUserId, rescueRecord.getUserId());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getTiringState())){
                wrapper.eq(RescueRecord::getTiringState, rescueRecord.getTiringState());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getCreateBy())){
                wrapper.like(RescueRecord::getCreateBy, rescueRecord.getCreateBy());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getCreateTime())){
                wrapper.eq(RescueRecord::getCreateTime, rescueRecord.getCreateTime());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getUpdateBy())){
                wrapper.like(RescueRecord::getUpdateBy, rescueRecord.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getUpdateTime())){
                wrapper.eq(RescueRecord::getUpdateTime, rescueRecord.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(rescueRecord.getRemark())){
                wrapper.like(RescueRecord::getRemark, rescueRecord.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
